﻿using System;

namespace Aeon.Emulator.Instructions.FPU
{
    internal static class Fyl2x
    {
        [Opcode("D9F1", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void ScaleLog2(VirtualMachine vm)
        {
            double st0 = vm.Processor.FPU.ST0;
            double st1 = vm.Processor.FPU.GetRegisterValue(1);

            // ST(1) = ST(1) * Log2(ST(0))
            st1 *= Math.Log(st0, 2.0);
            vm.Processor.FPU.SetRegisterValue(1, st1);
            vm.Processor.FPU.Pop();
        }
    }
}
